#!/usr/bin/env node

const inquirer = require("inquirer");
const path = require("path")
const fs = require("fs")
const ejs = require("ejs")
inquirer.prompt([
    {
        type:"input",
        name:"name",
        message:"project name"
    }
]).then(answer=>{
    console.log(answer)
    const tmlDir = path.join(__dirname,"templates")
    const outDir = process.cwd()
    fs.readdir(tmlDir,(err,files)=>{
        if(err) throw err;
        files.forEach(file=>{
            ejs.renderFile(path.join(tmlDir,file),answer,(error,res)=>{
                if(error) throw error;
                fs.writeFileSync(path.join(outDir,file),res)
            })
        })
    })
})